package com.niiwoo.civet.trade.dao.mapper;


import com.niiwoo.civet.trade.dao.entity.ProjectBorrowerSummary;
import com.niiwoo.civet.trade.dto.RefundListByUserDTO;
import com.niiwoo.civet.trade.dto.SummaryStatusDTO;
import com.niiwoo.civet.trade.dto.common.ProjectBorrowerSummaryDTO;
import com.niiwoo.civet.trade.enums.RepayStatusEnum;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;
import java.util.Set;

@Component
public interface ProjectBorrowerSummaryMapperExt extends ProjectBorrowerSummaryMapper {

    ProjectBorrowerSummary select(@Param("projectId") Long projectId,@Param("date") String date);

    List<ProjectBorrowerSummary> listWithhold(String date);

    List<String> refundByUsers(String date);

    List<String> refundAdvanceByUsers(String date);

    RefundListByUserDTO refundListByUsers(@Param("userId") String userId,@Param("date") String date);

    List<Long> listUserRepayProjectId(@Param("userId") String userId, @Param("date") String date);

    RefundListByUserDTO refundListForRepayemntGuarantee(@Param("refundDate") String refundDate);
    int updateByPrimaryKeyStatusSelective(SummaryStatusDTO summaryStatusDTO);
    /**
     * 根据还款状态统计数量
     * @param userId
     * @param repayStatusList
     * @return
     */
    long statisticsProjectCountByRepayStatus(@Param("userId") String userId, @Param("repayStatusList") List<Integer> repayStatusList);

    List<RefundListByUserDTO> refundListByUsers(String date);
    
    /**
     * 根据还款日查询待还款标的ID列表
     * @param refundDate
     * @return
     */
    Set<Long> queryWaitingRepaymentProjectIdSetByRefundDate(@Param("refundDate")Date refundDate);

    List<ProjectBorrowerSummaryDTO> queryMyLoanOverdue(String userId);

    int updateByPrimaryKeyCallBackSelective(ProjectBorrowerSummary summary);

    List<ProjectBorrowerSummary> queryMyLoanOverdueProjectList();

    List<Long> queryMyLoanOverdueProjectIdList();
    List<Long> queryOverdueProjectIdList();
    List<Long> queryBadProjectIdList(@Param("currentDate") Date currentDate);
    List<Long> queryNotBadProjectIdList(@Param("currentDate") Date currentDate);
    /**
     * 获取用户预期标的数量
     * @param userId
     * @return
     */
    int getOverdueProjectCount(@Param("userId") String userId);

    /**
     * 根据日期获取用户正常还款标的数量
     * @param userId
     * @param repaymentDate
     * @return
     */
    int getRepaymentsProjectCount(@Param("userId") String userId,@Param("repaymentDate") Date repaymentDate);

    /**
     * 查询项目借款（修改用）
     * @param projectId
     * @return
     */
    ProjectBorrowerSummary selectByPrimaryKeyForUpdate(@Param("projectId")Long projectId);

    List<ProjectBorrowerSummary> selectByRepayStatusList(@Param("repayStatusEnumList") List<RepayStatusEnum> repayStatusEnumList, @Param("differDaysList") List<Integer> differDaysList, @Param("offset") int offset, @Param("rows") int rows);

    List<ProjectBorrowerSummary> queryMyLoanOverdueProjectListByPage(@Param("offset") int offset, @Param("rows") int rows);

    /**
     * 查询资金端存在待还标的用户.
     *
     * @return 用户列表
     */
    List<ProjectBorrowerSummary> refundByUsers4Fund();

    /**
     * 查询资金端存在待还标的用户.
     *
     * @return 用户列表
     */
    List<ProjectBorrowerSummary> scheduleWithhold();
    
    /**
     * 查询资金端存特定用户代还款标.
     *
     * @return 代还款标的详情列表
     */
    RefundListByUserDTO refundListByUsers4Fund(String userId);

    /**
     * 查询标的逾期信息
     * @param projectId
     * @return
     */
    ProjectBorrowerSummary selectDueByProjectId(Long projectId);

    ProjectBorrowerSummary selectByUserIdAndProjectId(@Param("userId") String userId,@Param("projectId") Long projectId);

    /**
     * 查询逾期的应还款日期列表
     * @param userId
     * @return
     */
    List<Date> queryRefundDateList(@Param("userId") String userId);

    List<ProjectBorrowerSummary> selectBecomeOverdueProject(@Param("compareDate")Date compareDate);
}
